package com.sphd.emanu.activity;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;
import android.widget.Toast;

import com.sphd.emanu.R;
import com.sphd.emanu.activity.login.LoginContract;
import com.sphd.emanu.activity.login.LoginPresenter;
import com.sphd.emanu.mvp.MVPBaseActivity;
import com.wzutils.AppUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 关于界面
 *
 * @Author Hu
 * @Time 2017/4/7 -- 10:27.
 * @Email 87683202@qq.com
 */
public class AboutActivity extends AppCompatActivity {

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.ver_no)
    TextView verNo;
    @BindView(R.id.check_ver)
    TextView checkVer;
    @BindView(R.id.back_yj)
    TextView backYj;
    @BindView(R.id.ver_sm)
    TextView verSm;
    @BindView(R.id.help_user)
    TextView helpUser;
    @BindView(R.id.service_clause)
    TextView serviceClause;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
        initView();
        initEvent();
    }

    private void initEvent() {
        toolbar.setNavigationOnClickListener(v -> finish());
    }

    private void initView() {
        toolbar.setTitle("关于");
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        verNo.setText("版本号：v" + AppUtils.getVersionName(this));

    }

    @OnClick({R.id.check_ver, R.id.back_yj, R.id.ver_sm, R.id.help_user, R.id.service_clause})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.check_ver:
                break;
            case R.id.back_yj:
                Toast.makeText(this,"暂未开通",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ver_sm:
                Toast.makeText(this,"暂未开通",Toast.LENGTH_SHORT).show();
                break;
            case R.id.help_user:
                Toast.makeText(this,"暂未开通",Toast.LENGTH_SHORT).show();
                break;
            case R.id.service_clause:

                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                View webview = getLayoutInflater().inflate(R.layout.dialog_web, null);
                WebView webView = (WebView) webview.findViewById(R.id.web);
                webView.setWebViewClient(new WebViewClient());
                webView.loadUrl("file:///android_asset/about.html");
                builder.setTitle("用户协议");
                builder.setView(webview);
                builder.setPositiveButton("确定", null);
                builder.show();

                break;
        }
    }
}
